#include<func.h>
int g_num=0;
void signalHandler(int signum)
{
    int ret=g_num++;
    printf("before sleep,sig %d is coming,signum %d\n",signum,ret);
    sleep(3);
    printf("after sleep,sig %d is coming,signum %d\n",signum,ret);
}
int main()
{
    char buf[128]={0};
    int Rret;   
    if(SIG_ERR==signal(SIGINT,signalHandler))
    {
        printf("SIGINT fail\n");
    }
        if(SIG_ERR==signal(SIGQUIT,signalHandler))
    {
        printf("SIGQUIT fail\n");
    }
    do
    {
        memset(buf,0,sizeof(buf));
        Rret=read(STDIN_FILENO,buf,sizeof(buf)-1);
        ERROR_CHECK(Rret,-1,"read")
        printf("Get:%s",buf);
    }
        while(strcmp(buf,"quit\n")!=0);
    return 0;
}